/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.xinxi.dms.view;

import com.xinxi.dms.util.FrameUtil2;
import com.xinxi.dms.Util.LocationUtil;
import javax.swing.JInternalFrame;

/**
 *
 * @author zhigu
 */
public class MainFrame extends javax.swing.JFrame {

    /**
     * Creates new form MainJFrame
     */
    public MainFrame() {
        initComponents();
        //最大化
       LocationUtil.setFullScreen(this);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenu4 = new javax.swing.JMenu();
        jMenuBar2 = new javax.swing.JMenuBar();
        jMenu7 = new javax.swing.JMenu();
        jMenu8 = new javax.swing.JMenu();
        myDesktopPane1 = new com.xinxi.dms.view.MyDesktopPane();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        itemStudent = new javax.swing.JMenuItem();
        itemRoom = new javax.swing.JMenuItem();
        itemAdmin = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        itemIn = new javax.swing.JMenu();
        itemIn25 = new javax.swing.JMenuItem();
        itemIn23 = new javax.swing.JMenuItem();
        itemOut = new javax.swing.JMenu();
        itemOut25 = new javax.swing.JMenuItem();
        itemOut23 = new javax.swing.JMenuItem();
        itemChange = new javax.swing.JMenu();
        itemChange25 = new javax.swing.JMenuItem();
        itemChange23 = new javax.swing.JMenuItem();
        jMenu9 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();

        jMenu4.setText("jMenu4");

        jMenu7.setText("File");
        jMenuBar2.add(jMenu7);

        jMenu8.setText("Edit");
        jMenuBar2.add(jMenu8);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().add(myDesktopPane1, java.awt.BorderLayout.CENTER);

        jMenu1.setText("基础资料维护");

        itemStudent.setText("学生信息管理");
        itemStudent.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemStudentActionPerformed(evt);
            }
        });
        jMenu1.add(itemStudent);

        itemRoom.setText("学生宿舍管理");
        itemRoom.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemRoomActionPerformed(evt);
            }
        });
        jMenu1.add(itemRoom);

        itemAdmin.setText("管理员信息管理");
        itemAdmin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemAdminActionPerformed(evt);
            }
        });
        jMenu1.add(itemAdmin);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("宿舍管理");

        itemIn.setText("入住管理");

        itemIn25.setText("25号楼");
        itemIn25.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemIn25ActionPerformed(evt);
            }
        });
        itemIn.add(itemIn25);

        itemIn23.setText("23号楼");
        itemIn23.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemIn23ActionPerformed(evt);
            }
        });
        itemIn.add(itemIn23);

        jMenu2.add(itemIn);

        itemOut.setText("退宿管理");

        itemOut25.setText("25号楼");
        itemOut25.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemOut25ActionPerformed(evt);
            }
        });
        itemOut.add(itemOut25);

        itemOut23.setText("23号楼");
        itemOut23.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemOut23ActionPerformed(evt);
            }
        });
        itemOut.add(itemOut23);

        jMenu2.add(itemOut);

        itemChange.setText("调房管理");

        itemChange25.setText("25号楼");
        itemChange25.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemChange25ActionPerformed(evt);
            }
        });
        itemChange.add(itemChange25);

        itemChange23.setText("23号楼");
        itemChange23.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemChange23ActionPerformed(evt);
            }
        });
        itemChange.add(itemChange23);

        jMenu2.add(itemChange);

        jMenuBar1.add(jMenu2);

        jMenu9.setText("维修维护");
        jMenu9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu9ActionPerformed(evt);
            }
        });

        jMenuItem2.setText("维修管理");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu9.add(jMenuItem2);

        jMenuBar1.add(jMenu9);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void itemRoomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemRoomActionPerformed
        // TODO add your handling code here:
        openFrame(RoomFrame.class);
    }//GEN-LAST:event_itemRoomActionPerformed

    private void itemChange25ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemChange25ActionPerformed
        // TODO add your handling code here:
        openFrame(ChangeFrame_25.class);
    }//GEN-LAST:event_itemChange25ActionPerformed

    private void itemStudentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemStudentActionPerformed
        // TODO add your handling code here:
        //调用显示窗体的方法
        openFrame(StudentFrame.class);
    }//GEN-LAST:event_itemStudentActionPerformed

    private void itemAdminActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemAdminActionPerformed
        // TODO add your handling code here:
        openFrame(AdminFrame.class);
    }//GEN-LAST:event_itemAdminActionPerformed

    private void itemIn25ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemIn25ActionPerformed
        // TODO add your handling code here:
         openFrame(CheckinFrame_25.class);
    }//GEN-LAST:event_itemIn25ActionPerformed

    private void itemIn23ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemIn23ActionPerformed
        // TODO add your handling code here:
        openFrame(CheckinFrame_23.class);
    }//GEN-LAST:event_itemIn23ActionPerformed

    private void itemOut25ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemOut25ActionPerformed
        // TODO add your handling code here:
        openFrame(CheckoutFrame_25.class);
    }//GEN-LAST:event_itemOut25ActionPerformed

    private void itemOut23ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemOut23ActionPerformed
        // TODO add your handling code here:
        openFrame(CheckoutFrame_23.class);
    }//GEN-LAST:event_itemOut23ActionPerformed

    private void itemChange23ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemChange23ActionPerformed
        // TODO add your handling code here:
        openFrame(ChangeFrame_23.class);
    }//GEN-LAST:event_itemChange23ActionPerformed

    private void jMenu9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu9ActionPerformed

    }//GEN-LAST:event_jMenu9ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        // TODO add your handling code here:
        openFrame(MaintainFrame.class);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainFrame().setVisible(true);
            }
        });
    }

    private void openFrame(Class clazz){
            JInternalFrame frame = (JInternalFrame)FrameUtil2.buildFrame(clazz);
            //将窗体显示到面板上
            //1.
            this.myDesktopPane1.remove(frame);
            
            this.myDesktopPane1.add(frame);
            
            LocationUtil.setScreenCenter(frame);
            
            frame.setVisible(true);
            
            frame.toFront();
            
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem itemAdmin;
    private javax.swing.JMenu itemChange;
    private javax.swing.JMenuItem itemChange23;
    private javax.swing.JMenuItem itemChange25;
    private javax.swing.JMenu itemIn;
    private javax.swing.JMenuItem itemIn23;
    private javax.swing.JMenuItem itemIn25;
    private javax.swing.JMenu itemOut;
    private javax.swing.JMenuItem itemOut23;
    private javax.swing.JMenuItem itemOut25;
    private javax.swing.JMenuItem itemRoom;
    private javax.swing.JMenuItem itemStudent;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu7;
    private javax.swing.JMenu jMenu8;
    private javax.swing.JMenu jMenu9;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuBar jMenuBar2;
    private javax.swing.JMenuItem jMenuItem2;
    private com.xinxi.dms.view.MyDesktopPane myDesktopPane1;
    // End of variables declaration//GEN-END:variables
}
